package com.jing.intellij.apama.lang.psi

import com.intellij.lang.ASTNode
import com.intellij.lang.ParserDefinition
import com.intellij.lang.PsiParser
import com.intellij.lexer.Lexer
import com.intellij.openapi.project.Project
import com.intellij.psi.FileViewProvider
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.psi.TokenType
import com.intellij.psi.tree.IFileElementType
import com.intellij.psi.tree.TokenSet
import com.jing.intellij.apama.lang.EPLFlexAdapter
import com.jing.intellij.apama.lang.parser.EPLParser

class EPLParserDefinition: ParserDefinition {

    companion object {
        val FILE = IFileElementType(EPLLanguage.INSTANCE)
        val COMMENT = TokenSet.create(EPLTypes.COMMENT)
        val WHITE_SPACE = TokenSet.create(TokenType.WHITE_SPACE)
    }

    override fun createLexer(project: Project?): Lexer = EPLFlexAdapter()

    override fun createParser(project: Project?): PsiParser = EPLParser()

    override fun getFileNodeType(): IFileElementType = FILE

    override fun getCommentTokens(): TokenSet = COMMENT

    override fun getWhitespaceTokens(): TokenSet = WHITE_SPACE

    override fun getStringLiteralElements(): TokenSet = TokenSet.EMPTY

    override fun createElement(node: ASTNode?): PsiElement = EPLTypes.Factory.createElement(node)

    override fun createFile(viewProvider: FileViewProvider): PsiFile = EPLFile(viewProvider)
}